package com.lineage.server.clientpackets;

import com.lineage.echo.ClientExecutor;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.Instance.L1PetInstance;
import com.lineage.server.serverpackets.S_PetInventory;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.world.WorldPet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class C_PetMenu extends ClientBasePacket {
  private static final Log _log = LogFactory.getLog(C_PetMenu.class);
  
  public void start(byte[] decrypt, ClientExecutor client) {
    try {
      read(decrypt);
      L1PcInstance pc = client.getActiveChar();
      if (pc.isGhost() || pc.isTeleport() || pc.isPrivateShop())
        return; 
      int petId = readD();
      L1PetInstance pet = WorldPet.get().get(Integer.valueOf(petId));
      if (pet == null)
        return; 
      if (pc.getPetList().get(Integer.valueOf(petId)) == null)
        return; 
      pc.sendPackets((ServerBasePacket)new S_PetInventory(pet, true));
    } catch (Exception exception) {
    
    } finally {
      over();
    } 
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
